﻿using System;
using System.Windows;
using WickedFlame.Core.Shapes;

namespace WickedFlame.Core.State
{
    [Serializable]
    internal class LineMemento : ShapeMemento
    {
        Point _startPoint;
        Point _endPoint;

        public override void SaveProperties(VectorShape shape)
        {
            base.SaveProperties(shape);

            LineShape s = shape as LineShape;
            if (s != null)
            {
                _startPoint = s.StartPoint;
                _endPoint = s.EndPoint;
            }
        }

        public override void ResetProperties(VectorShape shape)
        {
            base.ResetProperties(shape);

            LineShape s = shape as LineShape;
            if (s != null)
            {
                s.StartPoint = _startPoint;
                s.EndPoint = _endPoint;
            }
        }

        public override VectorShape GenerateShape()
        {
            var shape = new LineShape();
            shape.ResetState(this);

            return shape;
        }
    }
}
